﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UCS.XNA.Draughts.Boards;

namespace UCS.XNA.Draughts.Pieces
{
    public class PieceMovement
    {
        #region Attributes and Properties

        private BoardPosition _boardMovement;
        public BoardPosition BoardMovement
        {
            get { return _boardMovement; }
        }

        private BoardPosition _jumpPosition;
        public BoardPosition JumpPosition
        {
            get { return _jumpPosition; }
        }

        public bool IsJump
        {
            get { return _jumpPosition != null; }
        }

        #endregion

        #region Constructors

        public PieceMovement(BoardPosition boardMovement)
        {
            this._boardMovement = boardMovement;
            this._jumpPosition = null;
        }

        public PieceMovement(BoardPosition boardMovement, BoardPosition jumpPosition)
        {
            this._boardMovement = boardMovement;
            this._jumpPosition = jumpPosition;
        }

        #endregion

        #region Public Methods

        public bool IsContraryOf(PieceMovement target)
        {
            if ((_jumpPosition != null && target.JumpPosition == null) ||
                (_jumpPosition == null && target.JumpPosition != null))
                return false;

            bool isContrary = _boardMovement.IsContraryOf(target.BoardMovement);

            if (_jumpPosition != null)
                return isContrary && _jumpPosition.IsContraryOf(target.JumpPosition);

            return isContrary;
        }

        #endregion
    }
}
